//
//  MyTableViewController.m
//  13-AutoLayout强化
//
//  Created by Snow on 16/8/1.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "MyTableViewController.h"
#define kReuse @"reuse"
#import "MyTableViewCell.h"
@interface MyTableViewController ()

@property (weak, nonatomic) IBOutlet MyTableViewCell *taclecell;
@property (nonatomic, strong) NSArray *array;
@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.array = [NSArray arrayWithObjects:@"寓居湘岸四无邻，世网难婴每自珍。莳药闲庭延国老，开樽虚室值贤人。泉回浅石依高柳，径转垂藤闲绿筠。闻道偏为五禽戏，出门鸥鸟更相亲", @"西陆动凉气，惊乌号北林。栖息岂殊性，集枯安可任。鸿鹄去不返，勾吴阻且深。徒嗟日沈湎，丸鼓骛奇音。东海久摇荡，南风已骎骎。坐使青天暮，小星愁太阴。众情嗜奸利，居货捐千金。危根一以振，齐斧来相寻。揽衣中夜起，感物涕盈襟。微霜众所践，谁念岁寒心。旭日照寒野，鸒斯起蒿", @"秋气集南涧，独游亭午时。回风一萧瑟，林影久参差。始至若有得，稍深遂忘疲。羁禽响幽谷，寒藻舞沦漪。去国魂已远，怀人泪空垂。孤生易为感，失路少所宜。索寞竟何事，徘徊只自知。谁为后来者，当与此心期", nil];
    [self.tableView registerClass:[MyTableViewCell class] forCellReuseIdentifier:kReuse];
    //1.自定义cell self-sizing ios8以后出的
    //预估高度
    self.tableView.estimatedRowHeight = 40;
    //高度 自动计算
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    //2.根据label内容 计算高度 并赋予tableview 
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    
    return self.array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    self.taclecell = [tableView dequeueReusableCellWithIdentifier:kReuse forIndexPath:indexPath];
    
    _taclecell.Mylable = _array[indexPath.row];
    return _taclecell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
